<?php
/**
 * @version		1.0.15.1 qcalc $
 * @package		qcalc
 * @copyright	Copyright © 2012 - All rights reserved.
 * @license		GNU/GPL
 * @author		Alexander Snitko
 * @author mail	a.lottis@gmail.com
 * @website		www.yoga-life.com.ua
 */
 
defined('_JEXEC') or die('Restricted access');
 
?>
<form action="index.php?option=com_qcalc&view=qcalc" method="post" name="adminForm">
<div id="editcell">
    <table class="adminlist">
    <thead>
        <tr>
            <th width="5">
                <?php echo JText::_( 'ID' ); ?>
            </th>
            <th width="20">   <!-- checkbox to check all company -->
                <input type="checkbox" name="toggle" value="" onclick="checkAll( <?php echo count($this->company); ?> );" />
            </th><th>
                <?php echo JText::_( 'Имя компании' ); ?>
            </th><th width="7%" nowrap="nowrap">
				<a title="Нажмите для сортировки по этому столбцу" href="javascript:tableOrdering('m.published','desc','');">Включен</a>		
			   </th><th>
                <?php echo JText::_( 'Филиал' ); ?>
            </th><th>
                <?php echo JText::_( 'Город' ); ?>
            </th><th>
                <?php echo JText::_( 'Адрес' ); ?>
            </th><th>
                <?php echo JText::_( 'web-сайт' ); ?>
            </th><th>
                <?php echo JText::_( 'E-mail' ); ?>
            </th><th>
                <?php echo JText::_( 'Телефоны' ); ?>
            </th>
        </tr>           
    </thead>
 
    <?php
    $k = 0;
 
    for ($i=0, $n=count( $this->company ); $i < $n; $i++)
    {
        $row = $this->company[$i];
        $checked = JHTML::_('grid.id', $i, $row->company_id );     //get checkbox HTML
        // get link HTML to edit task for this greeting
        $link = JRoute::_( 'administrator/index.php?option=com_qcalc&controller=qcalc&task=edit_company&cid[]='. $row->company_id );
    ?>
        <tr class="<?php echo "row$k"; ?>">
            <td>
                <?php echo $row->company_id; ?>
            </td><td>
                 <?php echo $checked; ?>
            </td><td>
                <a href="/<?php echo $link; ?>"><?php echo $row->company_name; ?></a>
            </td>
			   <td align="center">
				   <a title="<?=( (@$row->enabled) ? "Включить" : "Отключить" );?> компанию" id="e_a_<?=@$row->company_id;?>" pr_id="<?=@$row->company_id;?>" pr_val="<?=@$row->enabled;?>" onclick="return EnableCompany(this)" href="javascript:void(0);">
				   <img border="0" id="e_img_<?=@$row->company_id;?>" alt="<?=( (@$row->enabled) ? "Включен" : "Выключен" );?>" src="images/<?=( (@$row->enabled) ? "tick" : "publish_x" );?>.png"></a>
			   </td><td>
					<?php echo $row->pid_name; ?>
            </td><td>
					<?php echo $row->city; ?>
            </td><td>
                <?php echo $row->adress; ?>
            </td><td>
				   <?php echo "<a target=\"_blank\" href=\"http://$row->site\">$row->site</a>"; ?>
			   </td><td>
				   <?php echo "<a href=\"mailto:$row->mail\">$row->mail</a>".'&nbsp;&nbsp;&nbsp;&nbsp;';?>
			   </td><td>
                <?php echo $row->tel.'&nbsp;&nbsp;&nbsp;&nbsp;'; 
                echo $row->fax.'&nbsp;&nbsp;&nbsp;&nbsp;'; 
                 
                ?>
            </td>
        </tr>
    <?php
        $k = 1 - $k;    //switch row class
    }
    ?>
    </table>
</div>
<input type="hidden" name="option" value="com_qcalc" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="controller" value="qcalc" />
</form>

<script>

function EnableCompany(obj) {
   var id  = jQuery(obj).attr('pr_id');
   var val = jQuery(obj).attr('pr_val');
   jQuery.post("/administrator/index.php?option=com_qcalc&controller=qcalc&task=enable_company&no_html=1&id="+id+"&val="+val, null, function() { }, "script");
}

</script>
